<template>
  <div class="wrapper" ref="wrapper">
    <div class="content">
      <slot></slot>
    </div>
  </div>
</template>

<script>
import BScroll from "better-scroll"
export default {
  name: "Scroll",
  methods: {
  },
  data() {
    return {
      scroll: null,
      scrollPosition: 0
    }
  },
  props: {
    srcollType: {
      type: Number,
      default: 3
    }
  },
  methods: {
    watchScrollPosition() {
      this.scroll.on('scroll', res => {
        scrollY = Math.abs(Math.round(res.y))
        this.$emit('watchScrollY', scrollY)
      })
    }
  },
  mounted() {
    this.$nextTick(() => {
      this.scroll = new BScroll(this.$refs.wrapper, {
        probeType: this.srcollType,
        click: true,
        bounce: true,
        disableTouch: false,
        observeDOM: true,
        observeImage: true
      })
      this.watchScrollPosition()
    })
  }
}
</script>

<style scoped>

</style>